//
//  vdTMXNode.h
//  Void Dead
//
//  Created by Sidney Just on 31.01.10.
//
//  Copyright © 2009 by Sidney Just
//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
//  documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
//  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
//  and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
//  PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
//  FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
//  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#import <Foundation/Foundation.h>

#import "vdNode.h"
#import "vdAtlasShapeContainer.h"

#import "vdMacros.h"

#import "support/base64.h"
#import "support/gzip.h"

#import "vdTMXLayer.h"

#import "vdTextureContainer.h"

/**
 * \brief A node which can load .tmx files
 
 * This class can load .TMX files created with Tiled (<a href="http://www.mapeditor.org/">Tiled</a>) <br>
 * Currently only orthogonal maps are supported!
 **/
#ifdef USE_OS_40
@interface vdTMXNode : vdNode <NSXMLParserDelegate> {
#else
@interface vdTMXNode : vdNode {
#endif
	//\cond
	/**
	 * Tiles in X direction
	 **/
	int mapWidth;
	/**
	 * Tiles in Y direction
	 **/
	int mapHeight;
	
	/**
	 * Size of one tile in X direction
	 **/
	int tileHeight;
	/**
	 * Size of one tile in Y direction
	 **/
	int tileWidth;
	
	@private
	vdTMXLayer **container;
	int contLayer;
	
	vdTMXLayer *activeLayer;
	NSXMLParser *parser;
	
	unsigned int compression;
	unsigned int firstGid;
	
	NSMutableString *inputStr;
	NSArray *characterArray;
	
	int mapLoadState;
	int mapType;
	
	vdTextureContainer *textures;
	//\endcond
}
/**
 * Tiles in X direction
 **/
@property (readonly) int mapWidth;
/**
 * Tiles in Y direction
 **/
@property (readonly) int mapHeight;

/**
 * Size of one tile in X direction
 **/
@property (readonly) int tileHeight;
/**
 * Size of one tile in Y direction
 **/
@property (readonly) int tileWidth;

/**
 * Inits the node and loads the given map from the mainbundle
 @param _map Name of the map (eg. "map_01.tmx");
 @return Pointer to the TMX node.
 @remark using init: will throw an exception!
 **/
- (id)initWithMap:(NSString *)_map;

/**
 * Returns the pointer to the vdTMXLayer with the given name
 @param str Name of the layer (the name can be seen inside Tiled or the .tmx file!)
 @return Pointer to the vdTMXLayer or NULL if no layer with the given name exists.
 **/
- (vdTMXLayer *)getLayerWithName:(NSString *)str;

/**
 * Returns the next TMX Layer after the given TMX Layer. This can be used to loop through all TMX Layer in the node.
 @param _layer The TMX Layer from what you want to have the next TMX Layer or NULL if you want the first TMX Layer in this node.
 @return The next TMX Layer in the container or NULL if the given TMX Layer is the last TMX Layer.
 @remark The given TMX Layer must be in the node, otherwise the function returns NULL!
 **/
- (vdTMXLayer *)nextLayer:(vdTMXLayer *)_layer;

@end
